🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / testing / src / commonMain / kotlin / org / meshtastic / core / testing / FakeDatabaseManager.kt
Displaying Raw • Download
core/testing/src/commonMain/kotlin/org/meshtastic/core/testing/FakeDatabaseManager.kt 41414f832f938b655c97bc07509bc140ea16e2a3 (41414f83) Text, 2.67 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.testing
Tff7b72import T7ee787kotlinx.coroutines.flow.StateFlow
Tff7b72import T7ee787org.meshtastic.core.common.database.DatabaseManager
Tff7b72import T7ee787org.meshtastic.core.database.DatabaseConstants.MAX_CACHE_LIMIT
Tff7b72import T7ee787org.meshtastic.core.database.DatabaseConstants.MIN_CACHE_LIMIT
T8b949e/** A test double for [DatabaseManager] that provides a simple implementation and tracks calls. */
Tff7b72class T56d364FakeDatabaseManager Tb4b4b4:
Te6edf3BaseFakeTb4b4b4(Tb4b4b4)Tb4b4b4,
Te6edf3DatabaseManager Tb4b4b4{
Tff7b72private Tff7b72val Te6edf3_cacheLimit Tff7b72= Te6edf3mutableStateFlowTb4b4b4(Te6edf3DEFAULT_CACHE_LIMITTb4b4b4)
Tff7b72override Tff7b72val Te6edf3cacheLimitTb4b4b4: Te6edf3StateFlowTff7b72<Tffa657IntTff7b72> Tff7b72= Te6edf3_cacheLimit
Tff7b72var Te6edf3lastSwitchedAddressTb4b4b4: Tffa657String? Tff7b72= Tff7b72null
Tff7b72var Te6edf3lastAssociatedAddressTb4b4b4: Tffa657String? Tff7b72= Tff7b72null
Tff7b72var Te6edf3lastAssociatedNodeTb4b4b4: Tffa657Int? Tff7b72= Tff7b72null
Tff7b72var Te6edf3lastAssociatedDeviceIdTb4b4b4: Tffa657String? Tff7b72= Tff7b72null
Tff7b72val Te6edf3existingDatabases Tff7b72= Te6edf3mutableSetOfTff7b72<Tffa657StringTff7b72>Tb4b4b4(Tb4b4b4)
Tff7b72init Tb4b4b4{
Te6edf3registerResetAction Tb4b4b4{
Te6edf3_cacheLimitTb4b4b4.Te6edf3value Tff7b72= Te6edf3DEFAULT_CACHE_LIMIT
Te6edf3lastSwitchedAddress Tff7b72= Tff7b72null
Te6edf3lastAssociatedAddress Tff7b72= Tff7b72null
Te6edf3lastAssociatedNode Tff7b72= Tff7b72null
Te6edf3lastAssociatedDeviceId Tff7b72= Tff7b72null
Te6edf3existingDatabasesTb4b4b4.Te6edf3clearTb4b4b4(Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
Tff7b72override Tff7b72fun Td2a8ffgetCurrentCacheLimitTb4b4b4(Tb4b4b4)Tb4b4b4: Tffa657Int Tff7b72= Te6edf3_cacheLimitTb4b4b4.Te6edf3value
Tff7b72override Tff7b72fun Td2a8ffsetCacheLimitTb4b4b4(Te6edf3limitTb4b4b4: Tffa657IntTb4b4b4) Tb4b4b4{
Te6edf3_cacheLimitTb4b4b4.Te6edf3value Tff7b72= Te6edf3limitTb4b4b4.Te6edf3coerceInTb4b4b4(Te6edf3MIN_CACHE_LIMITTb4b4b4, Te6edf3MAX_CACHE_LIMITTb4b4b4)
Tb4b4b4}
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffswitchActiveDatabaseTb4b4b4(Te6edf3addressTb4b4b4: Tffa657String?Tb4b4b4) Tb4b4b4{
Te6edf3lastSwitchedAddress Tff7b72= Te6edf3address
Tb4b4b4}
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffassociateDeviceTb4b4b4(
Te6edf3addressTb4b4b4: Tffa657StringTb4b4b4,
Te6edf3nodeNumTb4b4b4: Tffa657IntTb4b4b4,
Te6edf3deviceIdTb4b4b4: Tffa657String?Tb4b4b4,
Te6edf3isSessionActiveTb4b4b4: Tb4b4b4(Tb4b4b4) Tff7b72-Tff7b72> Tffa657BooleanTb4b4b4,
Tb4b4b4) Tb4b4b4{
Tff7b72if Tb4b4b4(Te6edf3lastSwitchedAddress Tff7b72!Tff7b72= Te6edf3address Tff7b72|Tff7b72| Tff7b72!Te6edf3isSessionActiveTb4b4b4(Tb4b4b4)Tb4b4b4) Tff7b72return
Te6edf3lastAssociatedAddress Tff7b72= Te6edf3address
Te6edf3lastAssociatedNode Tff7b72= Te6edf3nodeNum
Te6edf3lastAssociatedDeviceId Tff7b72= Te6edf3deviceId
Tb4b4b4}
Tff7b72override Tff7b72fun Td2a8ffhasDatabaseForTb4b4b4(Te6edf3addressTb4b4b4: Tffa657String?Tb4b4b4)Tb4b4b4: Tffa657Boolean Tff7b72= Te6edf3address Tff7b72!Tff7b72= Tff7b72null Tff7b72&Tff7b72& Te6edf3existingDatabasesTb4b4b4.Te6edf3containsTb4b4b4(Te6edf3addressTb4b4b4)
Tff7b72companion Tff7b72object Tb4b4b4{
Tff7b72private Tff7b72const Tff7b72val Te6edf3DEFAULT_CACHE_LIMIT Tff7b72= T79c0ff1T79c0ff0T79c0ff0
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.12s